home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
getargs.arc
/
GETARGS.DOC
< prev
Wrap
Text File
|
1986-05-03
|
3KB
|
52 lines
Program: GETARGS
Author: Steve Titterud
Documentation: GETARGS.DOC (this file)
This is a little subroutine which might be used at the front end of
an Xywrite 3 program. It is, of course, subject to modification in
any degree the user might wish.
The basic purpose of this subroutine is to parse the argument passed
with a RUN command, break it into sub-arguments at the boundaries of
delimiters, enabling the user to enter a program with, say, 10 or 15
arguments instead of 1, for further use in the program.
The syntax is: RUN progname arg1[]arg2[]arg3[]arg4[].....argn[]
where []=delimiter specified by user in GETARGS.
In the form uploaded, the delimiter is specified as a comma (,) - this
can be found in the se /,/ command. Put anyone you like in there; just
make sure you won't use the delimiter within the arguments you intend to
pass!! The number and size of the arguments you will be able to pass to
the program depends on the resulting length of the command line. I don't
generally use a large number nor very large strings. Experiment around
and see what you can get away with. I can't seem to get more than 70
characters on a command line, including delimiters, no matter what I do.
Of course, if your arguments were small, you can store more than the 15
which getargs stores.
The program opens window #9, inserts the argument, then parses it, breaking
it into subarguments. Each subargument is captured to ALT-z, then assigned
to a numbered variable from 001 to 015, which are then available to your
program. I show that here by simply aborting the display of the entire
argument and inserting each subargument on its own line with the PV command,
in a new file, showargs. Note that the last subargument in the list must be
terminated with the delimiter also. Note also that if you have an ALT-z
macro loaded, it will be overwritten.
This will 'save' null variables in the order of 001-015, too - for example:
RUN getargs MN,IA,,,,WI,,IL,,,CA,,,OR,WA,
You may well want to have your program detect a null variable and branch
accordingly - getargs doesn't do this, as it is intended to demonstrate that
the argument passed with the RUN command can be broken down into subarguments,
each of which can be treated as a field for a certain type of value expected
to be initialized by this subroutine for further use in the main program.
I hope you find this idea useful at some point in time.
End of getargs.doc.